// src/main/java/com/example/ruleengine/rules/NewOrderRule.java
package com.example.ruleenginelearning.easyrule.rules;

import com.example.ruleenginelearning.example.model.Order;
import org.jeasy.rules.annotation.*;

@Rule(name = "NewOrderRule", description = "新订单处理规则")
public class NewOrderRule {

    @Condition
    public boolean isNewOrder(@Fact("order") Order order) {
        return "NEW".equals(order.getStatus());
    }

    @Action
    public void processNewOrder(@Fact("order") Order order) {
        System.out.printf("处理新订单 %s | 金额: %.2f%n", 
            order.getId(), order.getAmount());
        order.setStatus("PROCESSING");
    }

    @Priority
    public int getPriority() {
        return 1; // 高优先级
    }
}